package com.itheima.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
//@Component
@Slf4j
public class AdviceTypeAspect {
    @Pointcut("execution(* com.itheima.service.*.*(..))")
    public void pt(){

    }
    @Around("pt()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        log.info("-------AdviceTypeAspect  around 执行前--------------");
        Object proceed = proceedingJoinPoint.proceed();
        log.info("-------AdviceTypeAspect  around 执行后--------------");
        return proceed;
    }

    @Before("pt()")
    public void before(JoinPoint joinPoint) {
        log.info("-------AdviceTypeAspect  before --------------");
    }

    @After("pt()")
    public void after(JoinPoint joinPoint) {
        log.info("-------AdviceTypeAspect  after --------------");
    }

    @AfterReturning("pt()")
    public void afterReturning(JoinPoint joinPoint) {
        log.info("-------AdviceTypeAspect  afterReturning --------------");
    }

    @AfterThrowing("pt()")
    public void afterThrowing(JoinPoint joinPoint) {
        log.info("-------AdviceTypeAspect  afterThrowing --------------");
    }


}
